package communicationsSerwer;
import java.io.File;


public class UnZip {
   
	String fileName = new String();
	
	public UnZip (){
	
	try {
    	
      String path = new File(".").getCanonicalPath()+"\\ftp\\";
      String command = "cmd /c start "+path + "gzip.exe" + " -d "+ path + "*.Z";
         
      //System.out.println(command);
    	
      Process p = Runtime.getRuntime().exec(command);
      p.waitFor();
      //System.out.println(p.exitValue());
    }
    catch (Exception err) {
      err.printStackTrace();
    }
  }
	
	public UnZip (String file){
		
		//System.out.println("UnZip Start");
		
		try {
	    	
	      String path = new File(".").getCanonicalPath()+"\\ftp\\";
	      String command = path + "gzip.exe" + " -d "+ path + file;
	      
	      fileName = file.substring(0,file.length()-2);
	      
	      //System.out.println(command);
	    	
	      Process p = Runtime.getRuntime().exec(command);
	      p.waitFor();
	      //System.out.println(p.exitValue());
	    }
	    catch (Exception err) {
	      err.printStackTrace();
	    }
	   // System.out.println("UnZip END: rozpakowano: "+fileName);  
	}
	
	public String getFileName(){
		return fileName;
	}
	


}
